<div class="layuimini-main">
    <div class="layui-form layuimini-form" style="width: 80%;margin-top: 20px;" lay-filter="addScheduleForm">
        <div class="layui-form-item">
            <label class="layui-form-label required">日程标题</label>
            <div class="layui-input-block">
                <input type="text" name="schName" lay-verify="required" lay-reqtext="日程标题不能为空" placeholder="日程标题" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">日程内容</label>
            <div class="layui-input-block">
                <textarea name="schContent" placeholder="日程内容" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">日程时间</label>
            <div class="layui-input-block">
<!--                <textarea name="schTime" placeholder="日程时间" class="layui-textarea"></textarea>-->
                <input type="text" name="schTime" id="schTime" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
            </div>
        </div>

<!--        <div class="layui-inline">-->
<!--            <label class="layui-form-label">验证日期</label>-->
<!--            <div class="layui-input-inline">-->
<!--            </div>-->
<!--        </div>-->

        <div class="layui-form-item">
            <label class="layui-form-label required">日程地点</label>
            <div class="layui-input-block">
                <textarea name="schLocation" placeholder="日程地点" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">日程类型</label>
            <div class="layui-input-block">
                <select name="schPriority" lay-verify="required">
                    <option value="0">一般</option>
                    <option value="1">重要</option>
                    <option value="2">极其重要</option>
                </select>
            </div>
        </div>


        <div class="layui-form-item" style="text-align: center;margin-top: 30px;">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'table', 'axios', 'miniAdmin', 'laydate'], function () {
        let form = layui.form,
            layer = layui.layer,
            table = layui.table,
            axios = layui.axios,
            laydate = layui.laydate,
            miniAdmin = layui.miniAdmin,
            $ = layui.$;


        laydate.render({
            elem: '#schTime'
        });


        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        // 当前弹出层，防止ID被覆盖
        let parentIndex = layer.index;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            axios.post('schedule/create', data.field).then(function (response) {
                if(response.code === 200){
                    layer.msg(response.msg);                        // layer的成功提示
                }
                layer.close(parentIndex);                           // 关闭弹出层
            }).catch(function (error) {
                layer.msg(error);
            });
            return false;
        });




    });
</script>